

var checkPhone=function(str){
    if(!(/^1[34578]\d{9}$/.test(str))){
        return false;
    }else{
        return true;
    }
}

/**
 * //根据数组权重，随机返回下标
 * @param {Array} boxProbabilitys [1, 3, 4, 0.2]   下标3的权重最小，得到3的概率最小 
 */
var arrayRandom = function(boxProbabilitys){
    boxProbabilitys = boxProbabilitys.concat();
    //盒子概率权重 
    // let boxProbabilitys =  [0.01, 2, 1, 1, 1, 1, 9999];
    boxProbabilitys.unshift(0)
    let boxProbabilityMap = [0];
    let boxProbabilityWeight = boxProbabilitys.reduce((a, c) => {
        boxProbabilityMap.push(a + c); 
        return a + c;
    });
    let randomWeight = Math.random()*boxProbabilityWeight;
    let index = boxProbabilityMap.findIndex((pb)=>pb>randomWeight);
    //index 计算的索引值
    // console.log(index-1);

    return index-1;
};

var random = function(start, end, steps, interval){
    var range = Math.abs(start - end);
    steps = steps || Infinity;  //分成多少份
    interval = false;   //false 默认[0, 1)左闭右开区间   true [0, 1]闭区间

    let meta = range*Math.random();

    return start+Math.floor(range*Math.random()*steps)/steps
    // Math.floor(Math.random()*10)*range/steps

    // if(isFinite(step)){

    // }
}



let isDevelopment = (function () {
    // var host=window.location.host;
    let isDevelopment = Object.keys(Tida.appinfo).every(function(key){
        //所有信息都为false时，为开发模式
        return !Tida.appinfo[key]
    });
    // if(!isDevelopment){
    //     Tida.interactParams.appkey="123456";
    // }
    return isDevelopment;
})();

let isLocal = (function(){
    var host=window.location.host;
    return /^localhost|[\d\.]+$/.test(host);
})();


;(function(){
    let s = function(t) {
        //#42c02e 绿
        //#1475b2 蓝
        var e = t.title
          , r = t.content
          , n = t.backgroundColor  || '#1475b2'
          , i = ["%c ".concat(e, " %c ").concat(r, " "), 
          "padding: 1px; border-radius: 3px 0 0 3px; color: #fff; text-decoration: none; background: ".concat("#606060", ";"), 
          "padding: 1px; border-radius: 0 3px 3px 0; color: #fff; text-decoration: none; background: ".concat(n, ";")];
        return function() {
            var t;
            window.console && "function" === typeof window.console.log && (t = console).log.apply(t, arguments)
        }
        .apply(void 0, i);
    };
    window.console.env = s;
})();